package com.base.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import com.base.po.voip.Users;
import com.base.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.base.po.voip.Freeroutes;
import com.base.po.voip.FreeroutesExample;
import com.base.service.FreeroutesService;

@Controller
@RequestMapping("/admin")
public class content_tianjiaoem {
	@Autowired
	private UsersService usersService;
	@Autowired
	private FreeroutesService freeroutesService;

	// 账户信息
	@RequestMapping("/content_tianjiaoem")
	public ModelAndView index(HttpServletRequest request) throws Exception {
		// 返回ModelAndView
		ModelAndView modelAndView = new ModelAndView();
		if (request.getSession().getAttribute("adminUserId") == null) {
			modelAndView.setViewName("jsp/login");
			return modelAndView;
		}
		String adminUserId = (String) request.getSession().getAttribute("adminUserId");
		// 登陆商家
		Users user = usersService.selectByPrimaryKey(adminUserId);
		// 获取所有费率
		FreeroutesExample freeroutesExample = new FreeroutesExample();
		freeroutesExample.setOrderByClause("CreateTime");
		freeroutesExample.getOredCriteria().add(freeroutesExample.createCriteria().andDatastatusEqualTo(true));
		List<Freeroutes> freeroutes = freeroutesService.selectByExample(freeroutesExample);
		request.setAttribute("freeroutes", freeroutes);
		request.setAttribute("user", user);
		modelAndView.setViewName("jsp/content_tianjiaoem");
		return modelAndView;
	}

}
